<?php
include_once("../module/micro_stock/includes/plugin_micro_stock_class.php");
$microStock = new MicroStock();

$field = "sum(a.num) as totalProNum,b.username,b.name,a.member_id";
$cond = "";
if($_GET['memberId']){
    $cond .= " and a.member_id={$_GET['memberId']}";
}else{
    if($_GET['username']){
        $sql = "select userid from ".MEMBER." where (username like '%{$_GET['username']}%' or name like '%{$_GET['username']}%') limit 1";
        $db->query($sql);
        $userid = $db->fetchField('userid');
        if($userid){
            $cond .= " and a.member_id={$userid}";
        }
    }
}
//=============================
include_once("../includes/page_utf_class.php");
$page = new Page;
$page->listRows=20;
if (!$page->__get('totalRows')){
    $de['count']=$page->totalRows = $microStock->getMsTotalNum($cond);//总数
}
$de['count']=$de['count']?$de['count']:($_GET['totalRows']?$_GET['totalRows']:'0');
$de['page'] = $page->prompt();
$de['perPageRows'] = $page->listRows;
//=============================

//列表数据
$de['list'] = $microStock->getMsList($field,$cond,'',$page->firstRow,$page->listRows);

$tpl->assign('de',$de);
$tpl->display('micro_stock_shop.htm');